package com.cbtx.utils.ui

import android.app.Dialog
import android.content.Context
import android.graphics.drawable.AnimationDrawable
import android.os.Bundle
import android.text.TextUtils
import android.view.LayoutInflater
import android.widget.ImageView
import android.widget.TextView
import com.cbtx.utils.R

/**
 * author : joker.peng
 * e-mail : joker@fiture.com
 * date   : 2021/7/1 3:22 PM
 * desc   :
 */
class LoadingDialog(var mContext: Context, var content: String) : Dialog(mContext, R.style.LoadingDialog) {

    private lateinit var mTv1: TextView
    private lateinit var mImgLoad: ImageView
    private lateinit var animationDrawable: AnimationDrawable

    private var mContent: String? = null


    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        initView()
    }

    private fun initView() {
        var view = LayoutInflater.from(mContext).inflate(R.layout.layout_dialog_load, null)
        mTv1 = view.findViewById(R.id.id_dialog_load_tv_message)
        mImgLoad = view.findViewById(R.id.id_dialog_load_img)
        if (!TextUtils.isEmpty(mContent)) {
            mTv1.text = mContent
        }
        animationDrawable = mImgLoad.drawable as AnimationDrawable
        animationDrawable.start()
        setContentView(view)
    }


    fun setDialogContent(content: String) {
        mTv1.text = content
    }

}